package com.zzxy.springmvc5.controller;

import com.zzxy.springmvc5.po.Student;
import com.zzxy.springmvc5.po.studentExt;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.xml.ws.RequestWrapper;

@Controller
@RequestMapping("/stu")
public class StudentController {
    @RequestMapping("/register.do")
    public String register(){
        return "/user/register";
    }
    @RequestMapping("/insertStu.do")
    public@ResponseBody Student insertStu(@RequestBody Student student){
       student.setUsername(student.getUsername()+"123");
       student.setPassword(student.getPassword()+"456");
        return student;
    }
    @RequestMapping("addStu")
    public  String addStu( String username, String password){
        System.out.println(username);
        System.out.println(password);
        return"/user/list";
    }
    @RequestMapping("addStu1")
    public String addStu1(Student student){
        System.out.println(student.toString());
        return"/user/list";
    }
    @RequestMapping("addStu2")
    public String addStu1(studentExt ext){
            System.out.println(ext);
            return"/user/list";
    }
    @RequestMapping("test")
    public String test (){
        return "forward:/stu/register.do";
    }
    @RequestMapping("test1")
    public String test1 (){
        return "redirect:/stu/register.do";
    }
    @RequestMapping("add")
    public @ResponseBody Student add(@RequestBody Student student){
        student.setUsername(student.getUsername()+">>后端返回");
        student.setPassword(student.getPassword()+">>后端返回");
      return student;
    }
}
